package NiuKe;

import java.util.Scanner;

public class QueueEx {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());
        Queue q = new Queue(n);
        while(in.hasNextLine()){
            String tokens = in.nextLine();
            String[] inVal = tokens.split(" ");
            if(inVal[0].equals("push")){
                q.push(Integer.parseInt(inVal[1]));
            }else if(inVal[0].equals("pop")){
                q.pop();
            }else{
                q.front();
            }
        }
    }
    static class Queue{
        public int[] queue;
        int head = 0;
        int tail = 0;
        int size;
        public Queue(int n){
            // int n = Integer.parseInt(m);
            this.size = n;
            this.queue = new int[n];
        }
        public void push(int n){
            if(tail > size){
                System.out.println("error");
                return;
            }
            queue[tail++] = n;
        }
        public void pop(){
            if(head == tail){
                System.out.println("error");
                return;
            }
            int popV = queue[head++];
            System.out.println(popV);
        }
        public void front(){
            if(head == tail){
                System.out.println("error");
                return;
            }
            int popV = queue[head];
            System.out.println(popV);
        }
    }
}
